/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia.mecanismos;

import java.sql.Connection;
import java.util.Objects;

/**
 *
 * @author Walther Cardoso
 */
public abstract class PersistenceMechanism {
    
    private Connection connection;
    private String name;
    
    public String getName(){
        return this.name;
    }
    
    public Connection getConnection(){
        return connection;
    }
    
    protected void setConnection(Connection con){
        connection = con;
    }
    
    PersistenceMechanism(String name){
        this.name=name;
    }

    PersistenceMechanism() {}
    
    public abstract void open();
    
    public abstract boolean isOpen();
    
    public abstract void close();

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PersistenceMechanism other = (PersistenceMechanism) obj;
        if (!Objects.equals(this.name, other.name)) {
            return false;
        }
        return true;
    }

    public int hashCode() {
        int hash = 5;
        hash = 29 * hash + Objects.hashCode(this.name);
        return hash;
    }
    
}
